<template>
  <div>
    <!--条件筛选-->
    <FormPanel ref="formpanel" :list="formList" formType="show" :isSubmitBtn="false" :labelWidth=100 readonly="true">
    </FormPanel>
    <!-- table -->
    <BreakSpace label="权益变更记录" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable ref="table" :columns="columns" :dataSource="dataList" :datakey="'records'" :isSelectColumn="false"
      :onColumnsChange="columns => (this.columns = columns)" :isToperInfo="false" :isColumnFilter="false" :height="172"
      style="margin-bottom:20px;" />
    <div class="pdi-foot">
      <el-button size="small" type="primary" @click="closeDialog">返回</el-button>
    </div>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { detailMessage } from '@/api/repair/chargingPile/Query';

export default {
  name: 'detail',
  mixins: [dictionary],
  props: {
    formData: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      formList: this.createFormList(),
      columns: this.createTableColumns(),
      fetchParams: { xhrAbort: true },
      visibleDrawer: false,
      visibleImportPeij: false,
      handleType: '',

      title: '',
      initData: {},
      rowSelectData: [],
      dataList: []
    }
  },
  async created() {
    this.formList.forEach(x => {
      x.initialValue = this.formData[x.fieldName];
      x.disabled = true;
    });
    //this.dataList = await detailMessage(this.formData.id);
    let res = await detailMessage(this.formData.id);
    this.dataList = res.data;

  },

  methods: {
    closeDialog(type) {
      this.$emit('close', { visible: false, data: this.selectedRows, type: 'close' });
    },
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '充电桩权益',
          dataIndex: 'tramEquity',
          sorter: true,
          dictItems: this.createDictList('3047'),
        },
        {
          title: '权益使用状态',
          dataIndex: 'equityStatus',
          sorter: true,
          dictItems: this.createDictList('3048'),
        },
        {
          title: '工单号',
          dataIndex: 'workNo',
          sorter: true
        },
        {
          title: '工单状态',
          dataIndex: 'workStatus',
          dictItems: this.createDictList('3049'),
          sorter: true
        },
        {
          title: '安装进度',
          dataIndex: 'speedPro',
          sorter: true
        },
        {
          title: '更新人',
          dataIndex: 'updatedMan',
          sorter: true
        },

        {
          title: '更新时间',
          dataIndex: 'updatedTime',
          width: 200,
          sorter: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss',
        }
      ];
    },
    createFormList() {
      return [
        {
          type: 'BREAK_SPACE',
          label: '销售信息',
        },
        {
          type: 'INPUT',
          label: '销售订单编号',
          fieldName: 'xsddhm',
          initialValue: '',
        },
        {
          type: 'SELECT',
          label: '订单类型',
          initialValue: '',
          fieldName: 'xsddlx',
          itemList: this.createDictList('3050'),
        },
        {
          type: 'INPUT',
          label: '客户姓名',
          fieldName: 'customerName',

        },
        {
          type: 'INPUT',
          label: '客户手机号',
          fieldName: 'phone',
          initialValue: '',
        },
        {
          type: 'INPUT',
          label: 'VIN',
          fieldName: 'vin',
          initialValue: '',
          width: '200'
        },
        {
          type: 'DATE',
          label: '订单创建日期',
          fieldName: 'orderCreatedTime',
          initialValue: '',
          dateFormat: 'yyyy-MM-dd',

        },
        {
          type: 'BREAK_SPACE',
          label: '权益信息'
        },
        {
          type: 'SELECT',
          label: '充电桩权益',
          fieldName: 'tramEquity',
          initialValue: '',
          itemList: this.createDictList('3047'),

        },
        {
          type: 'SELECT',
          label: '权益使用状态',
          initialValue: '',
          fieldName: 'equityStatus',
          itemList: this.createDictList('3048'),
        },
        {
          type: 'INPUT',
          label: '工单号',
          initialValue: '',
          fieldName: 'workNo',
        },
        {
          type: 'SELECT',
          label: '工单状态',
          initialValue: '',
          fieldName: 'workStatus',
          itemList: this.createDictList('3049'),
        },

      ];
    },

    changeHandle(val) {
      console.log('输出的参数', val)
      this.fetchParams = Object.assign({}, val);

    },

  }
}
</script>

<style lang="less">
.pdi-foot {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid #d9d9d9;
}
</style>
